package com.Sony.TemplateGame;

import javax.microedition.khronos.opengles.GL10;

import org.anddev.andengine.entity.text.ChangeableText;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.font.FontFactory;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;

import android.graphics.Color;


/**
 *	Class untuk mengatur text
 *	@author sony wirawan
 **/
public class GameText 
{
	private TemplateGameActivity core;
	
	private Font mFont;
	private BitmapTextureAtlas mFontTexture;
	public ChangeableText mScoreText;
	public ChangeableText mDialogText;
	
	
	/**
	 *	Constructor scene1
	 *	@param BA = context yang digunakan
	 *	@author sony wirawan
	 **/
	public GameText(TemplateGameActivity template) 
	{	// TODO Auto-generated constructor stub
		this.core = template;
	}
	
	
	/**
	 *	method untuk memuat text texture
	 *	@author sony wirawan
	 **/
	public void loadResources() 
	{	// TODO Auto-generated method stub
		// Load the font we are going to use.
		FontFactory.setAssetBasePath("font/");
		this.mFontTexture = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
		this.mFont = FontFactory.createFromAsset(this.mFontTexture, this.core, "Droid.ttf", 16, true, Color.BLACK);
		this.core.getEngine().getTextureManager().loadTexture(this.mFontTexture);
		this.core.getEngine().getFontManager().loadFont(this.mFont);
		
		// The ScoreText showing how many points the pEntity scored.
		this.mScoreText = new ChangeableText(5, 5, this.mFont, "Score: 0", 200);
		this.mScoreText.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
		this.mScoreText.setPosition
		(	64, 0 );
		
		// The DialogText showing the dialog of player
		this.mDialogText = new ChangeableText(5, 5, this.mFont, "normal", 20);
		this.mDialogText.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
		this.mDialogText.setPosition
		(	this.core.player.sprite.getX(), this.core.player.sprite.getY()+10 );
	}
}
